package org.xteam.camllight.io;

import org.xteam.camllight.Primitive;
import org.xteam.camllight.Value;

public class OpenDescriptor implements Primitive {

	public Object exec(Object... args) {
		int fd = Value.longVal((Integer)args[0]);
		if (fd == 0) {
			return new Channel(System.in);
		}
		if (fd == 1) {
			return new Channel(System.out);
		}
		if (fd == 2) {
			return new Channel(System.err);
		}
		throw new RuntimeException("not implemented: OpenDescriptor(" + fd + ")");
	}

}
